package flyweight.example;

import java.util.HashMap;

/**
 * @author cheng:
 * @date 2019/4/25 11:08
 */
public class WebsiteFactory {

    private HashMap<String, Website> flyweights = new HashMap<>(16);

    public Website getWebsiteCategory(String key){
        if(!flyweights.containsKey(key)){
            flyweights.put(key, new ConcreteWebsite(key));
        }
        return flyweights.get(key);
    }

    public int getWebsiteCount(){
        return flyweights.size();
    }
}
